home *** CD-ROM | disk | FTP | other *** search
-
- #ifndef __IAPPLICATION_H_
- #define __IAPPLICATION_H_
- /*
- Peon - Win32 Games Programming Library
- Copyright (C) 2002-2005 Erik Yuzwa
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- Erik Yuzwa
- peon AT wazooinc DOT com
- */
-
- #include "IApplicationState.h"
-
- namespace peon
- {
- /**
- * This object is responsible for containing any "application global"
- * structures or handles. You should stick state-specific objects
- * into an IApplicationState instance, but any object that needs to be
- * referenced by all the internal states should be thrown into here
- */
- class PEONMAIN_API IApplication
- {
- protected:
- /** a hashmap container of our IApplicationState pointers */
- std::map<int, IApplicationState*> m_oStates;
-
- /** a handle to our current IApplicationState instance */
- IApplicationState* m_pCurrentState;
-
- public:
- /**
- * Constructor
- */
- IApplication();
-
- /**
- * Destructor
- */
- virtual ~IApplication();
-
- /**
- * This method is called when loading the game world. In here
- * we should be loading all of the internal IApplicationState instances
- * along with any "global level" objects
- * @return bool - true if successfull
- */
- virtual bool onLoadWorld() = 0;
-
- /**
- * This method is called when unloading the game world. Basically
- * any object that we created at a global level should be cleaned
- * up here.
- * Note that the IApplicationState instances are cleanup automatically,
- * so you do not need to worry about them.
- */
- virtual void onUnloadWorld() = 0;
-
- /**
- * This method is called when it's time to pass any rendering command
- * to the engine
- */
- virtual void onRenderWorld(){}
-
- /**
- * This method is called when it's time to update the objects in
- * the game world.
- * @param fElapsedTime - the time differential used for object position
- * calculations
- */
- virtual void onUpdateWorld( float fElapsedTime ) = 0;
-
- /**
- * This method is responsible for loading the
- * given IApplicationState along with registering it
- * into our hashtable
- * @param key - key id for the local hashmap
- * @param pState - a new @IApplicationState
- * @return bool - TRUE if everything initialized okay
- */
- bool loadState( int key, IApplicationState* pState );
-
- /**
- * This is an internal method to clean up all the states
- */
- void unloadStates();
-
- /**
- * This just returns the current IApplicationState that the engine
- * is working with.
- * @return IApplicationState* - a handle to the current IApplicationState
- */
- IApplicationState* getCurrentState(){ return m_pCurrentState; }
-
- /**
- * Set the current state to the one specified by the key identifier
- * param key - key to set current state to
- */
- void setCurrentState(int key);
-
- /**
- * This method is overrideable to provide quick keyboard access to the
- * current state
- * @param pEvent - a generated SDL_KeyboardEvent handle
- */
- virtual void onKeyEvent( SDL_KeyboardEvent* pEvent ){}
-
- /**
- * This method is overrideable to provide quick mouse access to the
- * current state
- * @param pEvent - a generated SDL_Event message
- */
- virtual void onMouseEvent( SDL_Event* pEvent ){}
-
- };
- }
-
- #endif
-
-